<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
</head>
<body>
<div class="layui-form timo-compile">
    <form th:action="@{/market/contract/save}">
        <input type="hidden" name="id" th:if="${contract}" th:value="${contract.id}">
        <input type="hidden" name="number" th:if="${contract}" th:value="${contract.number}">
        <div class="layui-form-item">
            <label class="layui-form-label">合同名称</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="name" placeholder="请输入合同名称"
                       th:value="${contract?.name}">
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">金额(万元)</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="price" placeholder="请输入金额(万元)"
                       th:value="${contract?.price}">
            </div>
            <label class="layui-form-label">付款方式</label>
            <div class="layui-input-inline">
                <select class="timo-search-select" name="payType" mo:dict="PAYTYPE"
                        mo-selected="${contract?.payType}" mo-empty=""
                        lay-verify="type"></select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">开始日期</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input start-calendar" name="startDate"
                       th:value="${#dates.format(contract?.startDate, 'yyyy-MM-dd')}">
            </div>
            <label class="layui-form-label">结束日期</label>
            <div class="layui-input-inline">
                <input type="text" class="layui-input end-calendar" name="endDate"
                       th:value="${#dates.format(contract?.endDate, 'yyyy-MM-dd')}">
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">客户名称</label>
            <div class="layui-input-inline">
                <select class="select" name="customerName" lay-search="">
                    <option value="">请选公司</option>
                    <span th:each="customer:${customers}">
                        <option th:text="${customer.name}"
                                th:selected="${contract?.customerName} == ${customer.name}"
                                th:value="${customer.name}"></option>
                    </span>
                </select>
            </div>
            <label class="layui-form-label">项目名称</label>
            <div class="layui-input-inline">
                <select class="select" name="porjectName" lay-search="">
                    <option value="">请选项目</option>
                    <span th:each="project:${projects}">
                        <option th:text="${project.name}"
                                th:selected="${contract?.porjectName} == ${project.name}"
                                th:value="${project.name}"></option>
                    </span>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">联系人</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="contact" placeholder="请输入联系人"
                       th:value="${contract?.contact}">
            </div>
            <label class="layui-form-label">联系人手机</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="phone" placeholder="请输入联系人手机"
                       th:value="${contract?.phone}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">客户签约人</label>
            <div class="layui-input-inline">
                <input class="layui-input" type="text" name="customerSigner" placeholder="请输入客户方签约人"
                       th:value="${contract?.customerSigner}">
            </div>
            <label class="layui-form-label">我方签约人</label>
            <div class="layui-input-inline">
                <select class="select" name="signer" lay-filter="signer" lay-search="">
                    <option value="">请选签约人</option>
                    <span th:each="user:${userList}">
                        <option th:text="${user.nickname}"
                                th:selected="${contract?.signer} == ${user.nickname}"
                                th:value="${user.nickname}"></option>
                    </span>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">负责人</label>
            <div class="layui-input-inline">
                <select class="select" name="userName" lay-filter="userName" lay-search="">
                    <option value="">请选负责人</option>
                    <span th:each="user:${userList}">
                        <option th:text="${user.nickname}"
                                th:selected="${contract?.userName} == ${user.nickname}"
                                th:value="${user.nickname}"></option>
                    </span>
                </select>
            </div>
            <label class="layui-form-label">协同人</label>
            <div style="width: 300px; display: inline-block; vertical-align: top;">
                <select name="partner" mo:list="${userMap}" xm-select="id" mo-selected="${partners}">
                </select>
            </div>

        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">附件</label>
            <div class="layui-input-inline ">
                <button id="PDF" type="button" class="layui-btn upload-file" name="attachment"
                        th:attr="up-url=@{/upload/file}"
                        up-field="path">
                    <i class="layui-icon">&#xe67c;</i>上传文件
                </button>
                <div class="upload-show-pdf">
                    <div class='upload-item'>
                        <input type="hidden" name="attachment" th:value="${contract?.attachment}"/>
                        [[${contract?.name}]]
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" class="layui-textarea"
                          name="remark">[[${contract?.remark}]]</textarea>
            </div>
        </div>
        <div class="layui-form-item timo-finally">
            <button class="layui-btn ajax-submit"><i class="fa fa-check-circle"></i> 保存</button>
            <button class="layui-btn btn-secondary close-popup"><i class="fa fa-times-circle"></i> 关闭</button>
        </div>
    </form>
</div>
<script th:replace="/common/template :: script"></script>
</body>
</html>